package enemies;

import android.content.Context;
import android.view.View;
import gameView.Ball;

public class SlowTracker extends Ball {
	private Ball Target;
	public SlowTracker(Context cxt, View v, Ball target, double speed, double radius) {
		super(cxt, v, 0.0, 0.0, radius);
		Target=target;
		setSpeed(speed);
	}
	@Override
	public void step() {
		double dist = distance(getX(), getY(), Target.getX(), Target.getY());
		setYV(getSpeed()*(Target.getY()-getY())/dist);
		setXV(getSpeed()*(Target.getX()-getX())/dist);
		super.step();
	}
	private double distance(double x1, double y1, double x2, double y2) {
		double c2 = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
		return Math.pow(c2, 1.0/2.0);
	}
}
